package com.situ.orderingsystem.utils;

import com.alibaba.fastjson2.JSON;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class Servlets {
    public static void renderJson(String str, HttpServletResponse resp){
        resp.setContentType("application/json;charset=utf-8");
        resp.setCharacterEncoding("utf-8");
        try {
        PrintWriter writer = resp.getWriter();
            writer.write(str);
            writer.flush();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
    public static  void renderJson(Object object,HttpServletResponse resp){
        renderJson(JSON.toJSONString(object),resp);
    }
}
